<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //函数参数的两种解构赋值和其默认值
        //return [] 解构赋值 返回多个值
        function add([x=0,y=0]=[]){
            console.log(x+y);
            return x+y;
        }
        // add([1,1]); 2
        // add([1]);   1
        // add([]);    0
        add();
        function some({x=0,y=0}={}){
            console.log(x+y);
            return x+y;
        }
        // some({x:12,y:11});
        // some({x:12});
        // some({});
        // some();
        function some1({x,y}={x:0,y:0}){
            console.log(x,y);
            return [x,y];
        }
        some1({x:12,y:11});
        some1({x:12});
        some1({});
        some1();

        //应用场景
        /**
         *  1.变量换值
         *  2.函数的参数默认值
         *  3.函数的多返回值提取
         *  4.函数参数顺序
         *  5.提取json数据 
         * 
         * 
         */

    </script>
</body>
</html>